/*
 * @Description:login页面
 * @Version: P0600_V1.1
 * @Author: chenm
 * @Date: 2020-09-19 21:53:45
 */
import React, { Component } from 'react';
import 'antd/dist/antd.css';
import { Button } from 'antd';
import { history } from 'umi';
import store from '../../services/login/index';
import { getTodoList } from '../../services/login/actionCreators';

class Login extends Component {
  constructor(props: Readonly<{}>) {
    super(props);
    store.subscribe(this.handleStoreChange);
  }

  state = store.getState();

  componentDidMount() {
    const action = getTodoList();
    store.dispatch(action);
  }

  handleStoreChange = () => {
    this.setState(store.getState());
  };

  goLink = () => {
    history.push('/index');
  };

  render() {
    const { list } = this.state;
    return (
      <div>
        <Button onClick={this.goLink} type="primary">
          跳转index页
        </Button>
        <p>{list}</p>
      </div>
    );
  }
}

export default Login;
